package com.txunda.zhuohired.aty.manage.home;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ants.theantsgo.view.inScroll.ListViewForScrollView;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.adapter.user.resume.PreviewEducationAdapter;
import com.txunda.zhuohired.adapter.user.resume.PreviewJobHistoryAdapter;
import com.txunda.zhuohired.adapter.user.resume.PreviewProjectAdapter;
import com.txunda.zhuohired.adapter.user.resume.PreviewSelfAdapter;
import com.txunda.zhuohired.aty.user.find.ShareAty;
import com.txunda.zhuohired.base.Base2Aty;
import com.txunda.zhuohired.view.ObservableScrollView;

import java.util.List;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/13 15:20
 * 功能描述：简历详情
 * 联系方式：jiahuanchen@126.com
 */

public class ManageResumeDetailsAty extends Base2Aty {
    /**
     * 标题
     */
    @ViewInject(R.id.tv_layout_manage_resume_details_center)
    private TextView tv_layout_manage_resume_details_center;
    /**
     * ObservableScrollView
     */
    @ViewInject(R.id.obs_scroll_view)
    private ObservableScrollView obs_scroll_view;
    /**
     * 工作经历
     */
    @ViewInject(R.id.lv_manage_resume_job_history)
    private ListViewForScrollView lv_manage_resume_job_history;
    /**
     * 教育经历
     */
    @ViewInject(R.id.lv_manage_resume_education)
    private ListViewForScrollView lv_manage_resume_education;
    /**
     * 项目经验
     */
    @ViewInject(R.id.lv_manage_resume_project)
    private ListViewForScrollView lv_manage_resume_project;
    /**
     * 社交主页
     */
    @ViewInject(R.id.lv_manage_resume_self)
    private ListViewForScrollView lv_manage_resume_self;
    /**
     * 收藏
     */
    @ViewInject(R.id.iv_layout_blue_collect)
    private ImageView iv_layout_blue_collect;

    private PreviewJobHistoryAdapter previewJobHistoryAdapter;
    private PreviewEducationAdapter previewEducationAdapter;
    private PreviewProjectAdapter previewProjectAdapter;
    private PreviewSelfAdapter previewSelfAdapter;

    private List jobList;
    private List educationList;
    private List projectList;
    private List socialList;

    private int collectStatus = 1;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showStatusBar(R.id.layout_manage_resume_details_head);
        tv_layout_manage_resume_details_center.setText("简历详情");
        obs_scroll_view.smoothScrollTo(0, 0);
        obs_scroll_view.scrollTo(0, 0);
        initCollect();
    }

    @Override
    @OnClick({R.id.iv_layout_blue_share, R.id.iv_layout_blue_collect})
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.iv_layout_blue_share:
                startActivity(ShareAty.class, null);
                break;
            case R.id.iv_layout_blue_collect://收藏
                if (collectStatus == 1) {
                    collectStatus = 2;
                    initCollect();
                } else {
                    collectStatus = 1;
                    initCollect();
                }
                break;
        }
    }

    private void initCollect() {
        if (collectStatus == 1) {
            iv_layout_blue_collect.setImageResource(R.mipmap.icon_manage_collect_no);
        } else {
            iv_layout_blue_collect.setImageResource(R.mipmap.icon_manage_collect);
        }
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.aty_manage_resume_details;
    }

    @Override
    protected void initialized() {

    }

    @Override
    protected void requestData() {
        initJobHistoryAdapter();
        initEducationAdapter();
        initProjectAdapter();
        initSelfAdapter();
    }

    private void initJobHistoryAdapter() {
        previewJobHistoryAdapter = new PreviewJobHistoryAdapter(this, jobList);
        lv_manage_resume_job_history.setAdapter(previewJobHistoryAdapter);
    }

    private void initEducationAdapter() {
        previewEducationAdapter = new PreviewEducationAdapter(this, educationList);
        lv_manage_resume_education.setAdapter(previewEducationAdapter);
    }

    private void initProjectAdapter() {
        previewProjectAdapter = new PreviewProjectAdapter(this, projectList);
        lv_manage_resume_project.setAdapter(previewProjectAdapter);
    }

    private void initSelfAdapter() {
        previewSelfAdapter = new PreviewSelfAdapter(this, socialList);
        lv_manage_resume_self.setAdapter(previewSelfAdapter);
    }

}
